package com.yami.shop.platform.task;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yami.shop.nft.common.model.NftRechargeActivity;
import com.yami.shop.nft.common.service.NftRechargeActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class GasActivityTask {

    @Autowired
    private NftRechargeActivityService nftRechargeActivityService;

    @XxlJob("gasActivityTask")
    public void gasActivityTask() {
        LambdaQueryWrapper<NftRechargeActivity> eq = new LambdaQueryWrapper<NftRechargeActivity>().eq(NftRechargeActivity::getStatus, 1);
        NftRechargeActivity one = nftRechargeActivityService.getOne(eq);
        one.setStatus(0);
        nftRechargeActivityService.updateById(one);
        NftRechargeActivity nftRechargeActivity = new NftRechargeActivity();
        nftRechargeActivity.setStatus(1);
        nftRechargeActivity.setActivityNum(2);
        nftRechargeActivity.setActivityName("能量免费活动");
        nftRechargeActivityService.save(nftRechargeActivity);
    }
}
